package some.point.dao;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;

import some.point.domain.PointCommand;


@Component
public class PointDaoImpl extends SqlSessionDaoSupport implements PointDao{

	@Override
	public List<PointCommand> pointList(String id) {
		List<PointCommand> list = getSqlSession().selectList("PointDao.historyList", id);
		return list;
	}

	@Override
	public int currPoint(String id) {
		int point = 0;
		List<PointCommand> list = getSqlSession().selectList("PointDao.historyList", id);
		for(PointCommand po : list){
			point += po.getPoint();
		}
		return point;
	}

	@Override
	public void deal(PointCommand pointCommand) {
		getSqlSession().update("PointDao.insertPoint", pointCommand);
	}

	@Override
	public int checkToday(Map<String, Object> map) {
		return getSqlSession().selectOne("PointDao.checkToday", map);
	}

}
